home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13027 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: "James E. Fuller" <jef@ix.netcom.com>
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 3 Apr 1996 19:14:53 -0600
  6. Organization: Fuller & Stone
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4jv7qd$da7@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j41ru$nq4@solutions.solon.com> <4jttlq$3p1@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Mailer: Mozilla 3.0B2 (WinNT; I)
  13.  
  14. Niall Smart wrote:
  15.  > 
  16.  > Michael Smith <msmith@mpx.com.au> wrote:
  17.  > 
  18.  > >Konrad Schwarz wrote:
  19.  > >>
  20.  > >> I recently wrote a loop that went like this:
  21.  > >>
  22.  > >> while (p < end_p)
  23.  > >>         ++*p++;
  24.  > >>
  25.  > 
  26.  > >This is largely a matter of taste
  27.  > 
  28.  > I would argue that it is far more than that.
  29.  > 
  30.  > >, but personally I don't like that
  31.  > >construct.  A programmer less skilled than you might easily misunderstand
  32.  > >that and introduce an error.  I would prefer:
  33.  > 
  34.  > >for ( ; p<end_p; p++)
  35.  > >       ++(*p);
  36.  > 
  37.  > or either of:
  38.  > 
  39.  > while (p < end_p)
  40.  > {
  41.  >         (*p)++;
  42.  >         p++;
  43.  > }
  44.  > 
  45.  > while (p++ < end_p)
  46.  > {
  47.  >         (*p)++;
  48.  > }
  49.  > 
  50.  > Zero chance for ambiguity in the last three versions.
  51.  > 
  52.  > Niall
  53.  
  54. I don't think that last one does the same stuff as the others.
  55.  
  56. Unambiguously or otherwise.
  57.